const fs = require('fs')

function getPromise (path) {
  return new Promise((resolve, reject) => {
    fs.readFile(`./${path}.txt`, 'utf-8', (err, data) => {
      if (data) {
        resolve(data)
      } else {
        reject(err)
      }
    })
  })
}

// new getPromise('a').then(data=>{
//     console.log(data);
//     return new getPromise('b')
// }).then(data=>{
//     console.log(data);
//     return new getPromise('c')
// }).then(data=>{
//     console.log(data);
// }).catch(err=>{
//     console.log(err);
// })

async function readFile () {
  try {
    let res1 = await getPromise('a')
    console.log(res1)
    let res2 = await getPromise('b')
    console.log(res2)
    let res3 = await getPromise('c')
    console.log(res3)
  } catch (error) {
      console.log(error);
  }
}

readFile()
